#include<bits/stdc++.h>
using namespace std;
#define int long long
int read(){
    int sum=0,k=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')k=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        sum=sum*10+(ch-'0');
        ch=getchar();
    }
    return sum*k;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x<=9)putchar(x+'0');
    else{
        print(x/10);
        putchar(x%10+'0');
    }
}
const int N=1e5+5;
int d[N],v[N],a[N],p[N];
vector<int>vis[N];
bool vis1[N];
bool vis2[N];
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t=read();
    while(t--){
        int n=read();
        int m=read();
        int l=read();
        int V=read();
        for(int i=1;i<=n;i++){
            d[i]=read();
            v[i]=read();
            a[i]=read();
        }
        for(int i=1;i<=m;i++)p[i]=read();
        int cnt=0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(p[j]>l)break;
                if(d[i]>p[j])continue;
                int s=p[j]-d[i];
                int v1=sqrt(pow(v[i],2)+2*a[i]*s);
                if(v1>V){
                    if(!vis1[i])cnt++;
                    vis1[i]=1;
                    vis[i].push_back(j);
                }
            }
        }
        int ans=0;
        for(int i=1;i<=m;i++){
            int cnt1=0;
            for(int j=1;j<=n;j++){
                if(!vis1[j]){
                    cnt1++;
                    continue;
                }
                bool flg=0;
                for(int k:vis[j]){
                    if(k==i){
                        flg=1;
                        break;
                    }
                }
                if(vis[j].size()-1||(!flg))cnt1++;
            }
            if(cnt1==n)vis2[i]=1;
            if(vis2[i]){
                ans++;
                for(int j=1;j<=n;j++){
                    if(!vis1[j])continue;
                    vector<int>::iterator it;
                    for(it=vis[j].begin();it!=vis[j].end();it++){
                        if(*it==i){
                            vis[j].erase(it);
                            break;
                        }
                    }
                }
            }
        }
        print(cnt);
        putchar(' ');
        print(ans);
        putchar('\n');
    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/
